- /* sdodvdbl.cpp by K.Tsuru */
- // function ID = 334 DRADIX
- /*****************
- SDouble class
- divide by double
- ******************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- static const char* func = "SD/double";
- SDouble operator/(const SDouble& m, double n){
- if(n == 0.0) m.SetError(m.DIVIDED_BY_ZERO, func, 334);
- if(m.Sign(334) == 0) return SDZero(m);
- //This is not necessary because an access error occurs for SDecimal.
- // if(m.Type() != m.REAL) m.SetError(m.RADIX_ERR, func, 334);
- // must use XsDiv() for SDecimal class
-
- long N;
- double mt = (double)m.SlOpMaxValue();
- int d2l, e;
- d2l = doubleTolongExp(n, &N, &e, mt); //Try to convert into n = N*10^e.
- if(d2l){ //divide by N*10^e
- ulong p = (ulong)labs(N);
- SDouble r;
- if(p != 1uL) r = DsDiv(m, p); // r = m/|N|
- else r = m;
- //Maybe r becomes zero in the fixed point mode.
- if( r.Sign(334) ){
- r.SetSign(m.Sign()*Sgn(n));
- if(e) r.MultPow10(-e); // r = m*10^(-e)/|N| = m/|n|
- }
- return r;
- }
- return m*DReciprocal( SDouble(n) ); // add SDouble() since version 2.192
- }
sdodvdbl.cpp : last modifiled at 2014/05/21 21:50:13(1,080 bytes)
created at 2017/10/07 10:21:14
The creation time of this html file is 2017/10/07 10:30:03 (Sat Oct 07 10:30:03 2017).